<script>

//初始化插件
const printerModule = uni.requireNativePlugin("PrinterModule")
export default {
    methods: {
        /*初始化设备*/
        initDevice() {
            // 是否有全部权限
            const result = printerModule.hasAllPermission();
            if (result && result.success) {
                //执行其他
            } else {
                uni.showToast({
                    title: '权限不足，请重新申请权限！!',
                    icon: 'success',
                    duration: 2000
                });
                setTimeout(() => {
                    uni.hideToast();
                }, 2000);
                printerModule.requestPermissions();
            }
            // 启动服务
            printerModule.startService()
        }
    },
    mounted() {
        uni.hideToast(); // 手动关闭
    },
    onLaunch: function () {
        console.log('App Launch')
        plus.navigator.hideSystemNavigation();

        this.initDevice();
    },
    onShow: function () {
        console.log('App Show')
    },
    onHide: function () {
        console.log('App Hide')
    }
}
</script>

<style lang="scss">
/*每个页面公共css */
</style>
